//
//  viewwwwwwww.m
//  30201
//
//  Created by student on 16/4/6.
//  Copyright © 2016年 NIIT. All rights reserved.
//

#import "viewwwwwwww.h"

@implementation viewwwwwwww
-(void)drawRect:(CGRect)rect
{
    [self draw1];
    [self draw2];
    [self draw3];
    [self draw4];
    [self draw5];
    [self draw6];
    [self draw7];
    [self draw8];
}
-(void)draw1
{
    CGContextRef ctx=UIGraphicsGetCurrentContext();
    CGMutablePathRef path=CGPathCreateMutable();
    CGPathMoveToPoint(path, NULL, 50, 50);
    CGPathAddLineToPoint(path, NULL, 200, 200);
    CGContextAddPath(ctx, path);
    CGContextStrokePath(ctx);
}
-(void)draw2
{
    CGContextRef ctx=UIGraphicsGetCurrentContext();
    CGContextMoveToPoint(ctx, 50, 50);
    CGContextAddLineToPoint(ctx, 150, 200);
    CGContextStrokePath(ctx);
}
-(void)draw3
{
    UIBezierPath *path=[UIBezierPath bezierPath];
    [path moveToPoint:CGPointMake(50, 50)];
    [path addLineToPoint:CGPointMake(250, 200)];
    [path stroke];
}
-(void)draw4
{
    CGContextRef ctx=UIGraphicsGetCurrentContext();
    CGContextMoveToPoint(ctx, 50, 50);
    CGContextAddLineToPoint(ctx, 100, 50);
    CGContextAddLineToPoint(ctx, 100, 100);
    [[UIColor redColor] setStroke];
    CGContextSetLineWidth(ctx, 10);
    CGContextSetLineJoin(ctx, kCGLineJoinBevel);
    CGContextStrokePath(ctx);
}
-(void)draw5
{
    UIBezierPath *path=[UIBezierPath bezierPath];
    [path moveToPoint:CGPointMake(50, 50)];
    [path addLineToPoint:CGPointMake(50, 100)];
    path.lineWidth=10;
    [[UIColor greenColor] setStroke];
    [path stroke];
    UIBezierPath *path2=[UIBezierPath bezierPath];
    [path2 moveToPoint:CGPointMake(50, 100)];
    [path2 addLineToPoint:CGPointMake(50, 150)];
    path2.lineWidth=10;
    [[UIColor greenColor] setStroke];
    [path2 stroke];
}
-(void)draw6
{
    CGContextRef ctx=UIGraphicsGetCurrentContext();
    CGContextMoveToPoint(ctx, 50, 50);
    CGContextAddQuadCurveToPoint(ctx, 150, 250, 250, 200);
    [[UIColor redColor]setStroke];
    [[UIColor redColor]setFill];
    CGContextFillPath(ctx);
}
-(void)draw7
{
    UIBezierPath *path=[UIBezierPath bezierPathWithRoundedRect:CGRectMake(50, 50, 200, 200) cornerRadius:100];
    [[UIColor yellowColor] setStroke];
    [[UIColor greenColor] setFill];
    path.lineWidth=50;
    [path stroke];
    [path fill];
}
-(void)draw8
{
    UIBezierPath *path=[UIBezierPath bezierPath];
    [path moveToPoint:CGPointMake(125, 125)];
    [path addArcWithCenter:CGPointMake(125, 125) radius:100 startAngle:0 endAngle:M_PI_2 clockwise:YES];
    [path closePath];
    [[UIColor whiteColor] setStroke];
    path.lineWidth=5;
    [path stroke];
    [path fill];
}
@end
